<%@ page language="java" contentType="text/html; charset=UTF-8"
    pageEncoding="UTF-8"%>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<title>数据规则</title>
  <link href="${root}/js/lib/ligerUI/skins/Aqua/css/ligerui-all.css" rel="stylesheet" type="text/css" />
    <link href="${root}/js/lib/ligerUI/skins/Gray/css/all.css" rel="stylesheet" type="text/css" />
    <script src="${root}/js/lib/jquery/jquery-1.5.2.min.js" type="text/javascript"></script>
    <script src="${root}/js/lib/ligerUI/js/ligerui.min.js" type="text/javascript"></script>
    <script src="${root}/js/lib/ligerUI/js/ligerui.all.js" type="text/javascript"></script>
    <link href="${root}/js/lib/css/common.css" rel="stylesheet" type="text/css" />  
    <script src="${root}/js/common/common.js" type="text/javascript"></script>    
    <script src="${root}/js/common/LG.js" type="text/javascript"></script>   
    <script src="${root}/js/common/ligerui.expand.js" type="text/javascript"></script> 
    <script src="${root}/js/lib/json2.js" type="text/javascript"></script>
    
    <script src="${root}/js/lib/ligerUI/js/plugins/ligerGrid.js" type="text/javascript"></script>
    <script src="${root}/js/lib/ligerUI/js/plugins/ligerLayout.js" type="text/javascript"></script>
     <script src="${root}/js/lib/jquery-validation/jquery.validate.min.js" type="text/javascript"></script> 
    <script src="${root}/js/lib/jquery-validation/jquery.metadata.js" type="text/javascript"></script>
    <script src="${root}/js/lib/jquery-validation/messages_cn.js" type="text/javascript"></script> 
</head>

<style type="text/css">
    .filterpanle{ margin:10px;}
    .l-panel td.l-filter-column,.l-panel td.l-filter-value,.l-panel td.l-filter-op{ padding:2px;}
    
    .l-selected .l-grid-row-cell, .l-selected {background: #F5F5F5;}
    .l-panel td .l-filter-rowlast{ padding-top:1px;}
    
    .l-panel td .l-filter-rowlast {padding:3px;}
        .l-panel td .groupopsel{ margin:1px;}
        .l-panel td .l-filter-cellgroup{ padding:2px;}  
         .l-panel td .l-filter-rowlastcell{ padding:2px;}
</style>
<%
   	String id = request.getParameter("ID");
%>
<body  style="padding:2px;height:100%; text-align:center;">
<div id="rightgrid"  style="margin:2px;"></div>
	       		  
<script type="text/javascript">
	LG.overrideGridLoading(); 
	//相对路径
    var rootPath = "${root}/app/";
    
    //权限 保存按钮
    var toolbarOptions = {
        items: [
        { text: '保存', click: f_save, img: "${root}/js/lib/icons/silkicons/page_save.png" }
    ]
    };
    
  
    var grid = $("#rightgrid").ligerGrid({
        columns: [
        { display: "主键", name: "rule_id", hide:true, width: '10%', type: "text", align: "left" },
        { display: "名称", name: "name", width: '10%', type: "text", align: "left" },
        { display: "类型", name: "isPublie", width: '10%', type: "text", align: "left" },
        { display: "描述", name: "remark", width: '80%', type: "text", align: "left" }
        ], 
        dataAction: 'server', 
        pageSize: 20, 
        toolbar: toolbarOptions,
        url: rootPath + 'sys_rule_loadJSON', 
        sortName: 'name', 
        width: '98%', 
        height: '100%',
        heightDiff:-10, 
        checkbox: true,
        usePager:true,
        enabledEdit: false, 
        clickToEdit: false,
        mouseoverRowCssClass : null,
        alternatingRow :false
    }); 
    
    //var rows1 = grid.getSelecteds();
    //权限保存
    function f_save()
    {	
    	 var rows = grid.getSelecteds();
    	 var id = <%=id%>;
    	 var str = "";
    	 $(rows).each(function(){
			str+= this.rule_id+",";
    	 }) ;
    	 
    	 LG.ajax({
             loading: '正在保存权限设置中...',
             type: '/addRolePrivilege',
             //method: selectedRoleID ? 'SaveRolePermission' : 'SaveUserPermission',
             data: {
                 DataJSON: JSON2.stringify(data),
                 RoleId: selectedRoleID
                // UserID: selectedUserID
             },
             success: function ()
             {
                 LG.showSuccess("保存成功!");
             },
             error: function (message)
             {
                 LG.showError(message);
             }
         });
    	 
    }
    
</script>
</body>
</html>